// compile: g++ -o initializer_list initializer_list.cc -std=c++11
// run: ./initializer_list
#include <initializer_list>
#include <iostream>
#include <vector>
class MagicFoo {
 public:
  std::vector<int> vec;
  // 初始化列表构造函数
  MagicFoo(std::initializer_list<int> list) {
    for (std::initializer_list<int>::iterator it = list.begin();
         it != list.end(); ++it)
      vec.push_back(*it);
  }
};
int main() {
  // after C++11
  MagicFoo magicFoo{1, 2, 3, 4, 5};
  std::cout << "magicFoo: " << std::endl;
  for (std::vector<int>::iterator it = magicFoo.vec.begin();
       it != magicFoo.vec.end(); ++it)
    std::cout << *it << std::endl;
}
